home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / include / drm / via_drm.h < prev   
Encoding:
C/C++ Source or Header  |  2009-09-09  |  8.1 KB  |  274 lines

  1. /*
  2.  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  3.  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the "Software"),
  7.  * to deal in the Software without restriction, including without limitation
  8.  * the rights to use, copy, modify, merge, publish, distribute, sub license,
  9.  * and/or sell copies of the Software, and to permit persons to whom the
  10.  * Software is furnished to do so, subject to the following conditions:
  11.  *
  12.  * The above copyright notice and this permission notice (including the
  13.  * next paragraph) shall be included in all copies or substantial portions
  14.  * of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  19.  * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22.  * DEALINGS IN THE SOFTWARE.
  23.  */
  24. #ifndef _VIA_DRM_H_
  25. #define _VIA_DRM_H_
  26.  
  27. /* WARNING: These defines must be the same as what the Xserver uses.
  28.  * if you change them, you must change the defines in the Xserver.
  29.  */
  30.  
  31. #ifndef _VIA_DEFINES_
  32. #define _VIA_DEFINES_
  33.  
  34. #include "via_drmclient.h"
  35.  
  36. #define VIA_NR_SAREA_CLIPRECTS        8
  37. #define VIA_NR_XVMC_PORTS               10
  38. #define VIA_NR_XVMC_LOCKS               5
  39. #define VIA_MAX_CACHELINE_SIZE          64
  40. #define XVMCLOCKPTR(saPriv,lockNo)                    \
  41.     ((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
  42.                       (VIA_MAX_CACHELINE_SIZE - 1)) &    \
  43.                      ~(VIA_MAX_CACHELINE_SIZE - 1)) +    \
  44.                     VIA_MAX_CACHELINE_SIZE*(lockNo)))
  45.  
  46. /* Each region is a minimum of 64k, and there are at most 64 of them.
  47.  */
  48. #define VIA_NR_TEX_REGIONS 64
  49. #define VIA_LOG_MIN_TEX_REGION_SIZE 16
  50. #endif
  51.  
  52. #define VIA_UPLOAD_TEX0IMAGE  0x1    /* handled clientside */
  53. #define VIA_UPLOAD_TEX1IMAGE  0x2    /* handled clientside */
  54. #define VIA_UPLOAD_CTX        0x4
  55. #define VIA_UPLOAD_BUFFERS    0x8
  56. #define VIA_UPLOAD_TEX0       0x10
  57. #define VIA_UPLOAD_TEX1       0x20
  58. #define VIA_UPLOAD_CLIPRECTS  0x40
  59. #define VIA_UPLOAD_ALL        0xff
  60.  
  61. /* VIA specific ioctls */
  62. #define DRM_VIA_ALLOCMEM    0x00
  63. #define DRM_VIA_FREEMEM            0x01
  64. #define DRM_VIA_AGP_INIT    0x02
  65. #define DRM_VIA_FB_INIT            0x03
  66. #define DRM_VIA_MAP_INIT    0x04
  67. #define DRM_VIA_DEC_FUTEX       0x05
  68. #define NOT_USED
  69. #define DRM_VIA_DMA_INIT    0x07
  70. #define DRM_VIA_CMDBUFFER    0x08
  71. #define DRM_VIA_FLUSH            0x09
  72. #define DRM_VIA_PCICMD            0x0a
  73. #define DRM_VIA_CMDBUF_SIZE    0x0b
  74. #define NOT_USED
  75. #define DRM_VIA_WAIT_IRQ        0x0d
  76. #define DRM_VIA_DMA_BLIT        0x0e
  77. #define DRM_VIA_BLIT_SYNC       0x0f
  78.  
  79. #define DRM_IOCTL_VIA_ALLOCMEM      DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
  80. #define DRM_IOCTL_VIA_FREEMEM      DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
  81. #define DRM_IOCTL_VIA_AGP_INIT      DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
  82. #define DRM_IOCTL_VIA_FB_INIT      DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
  83. #define DRM_IOCTL_VIA_MAP_INIT      DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
  84. #define DRM_IOCTL_VIA_DEC_FUTEX   DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
  85. #define DRM_IOCTL_VIA_DMA_INIT      DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
  86. #define DRM_IOCTL_VIA_CMDBUFFER      DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
  87. #define DRM_IOCTL_VIA_FLUSH      DRM_IO(  DRM_COMMAND_BASE + DRM_VIA_FLUSH)
  88. #define DRM_IOCTL_VIA_PCICMD      DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
  89. #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
  90.                         drm_via_cmdbuf_size_t)
  91. #define DRM_IOCTL_VIA_WAIT_IRQ    DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
  92. #define DRM_IOCTL_VIA_DMA_BLIT    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
  93. #define DRM_IOCTL_VIA_BLIT_SYNC   DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
  94.  
  95. /* Indices into buf.Setup where various bits of state are mirrored per
  96.  * context and per buffer.  These can be fired at the card as a unit,
  97.  * or in a piecewise fashion as required.
  98.  */
  99.  
  100. #define VIA_TEX_SETUP_SIZE 8
  101.  
  102. /* Flags for clear ioctl
  103.  */
  104. #define VIA_FRONT   0x1
  105. #define VIA_BACK    0x2
  106. #define VIA_DEPTH   0x4
  107. #define VIA_STENCIL 0x8
  108. #define VIA_MEM_VIDEO   0    /* matches drm constant */
  109. #define VIA_MEM_AGP     1    /* matches drm constant */
  110. #define VIA_MEM_SYSTEM  2
  111. #define VIA_MEM_MIXED   3
  112. #define VIA_MEM_UNKNOWN 4
  113.  
  114. typedef struct {
  115.     uint32_t offset;
  116.     uint32_t size;
  117. } drm_via_agp_t;
  118.  
  119. typedef struct {
  120.     uint32_t offset;
  121.     uint32_t size;
  122. } drm_via_fb_t;
  123.  
  124. typedef struct {
  125.     uint32_t context;
  126.     uint32_t type;
  127.     uint32_t size;
  128.     unsigned long index;
  129.     unsigned long offset;
  130. } drm_via_mem_t;
  131.  
  132. typedef struct _drm_via_init {
  133.     enum {
  134.         VIA_INIT_MAP = 0x01,
  135.         VIA_CLEANUP_MAP = 0x02
  136.     } func;
  137.  
  138.     unsigned long sarea_priv_offset;
  139.     unsigned long fb_offset;
  140.     unsigned long mmio_offset;
  141.     unsigned long agpAddr;
  142. } drm_via_init_t;
  143.  
  144. typedef struct _drm_via_futex {
  145.     enum {
  146.         VIA_FUTEX_WAIT = 0x00,
  147.         VIA_FUTEX_WAKE = 0X01
  148.     } func;
  149.     uint32_t ms;
  150.     uint32_t lock;
  151.     uint32_t val;
  152. } drm_via_futex_t;
  153.  
  154. typedef struct _drm_via_dma_init {
  155.     enum {
  156.         VIA_INIT_DMA = 0x01,
  157.         VIA_CLEANUP_DMA = 0x02,
  158.         VIA_DMA_INITIALIZED = 0x03
  159.     } func;
  160.  
  161.     unsigned long offset;
  162.     unsigned long size;
  163.     unsigned long reg_pause_addr;
  164. } drm_via_dma_init_t;
  165.  
  166. typedef struct _drm_via_cmdbuffer {
  167.     char *buf;
  168.     unsigned long size;
  169. } drm_via_cmdbuffer_t;
  170.  
  171. /* Warning: If you change the SAREA structure you must change the Xserver
  172.  * structure as well */
  173.  
  174. typedef struct _drm_via_tex_region {
  175.     unsigned char next, prev;    /* indices to form a circular LRU  */
  176.     unsigned char inUse;    /* owned by a client, or free? */
  177.     int age;        /* tracked by clients to update local LRU's */
  178. } drm_via_tex_region_t;
  179.  
  180. typedef struct _drm_via_sarea {
  181.     unsigned int dirty;
  182.     unsigned int nbox;
  183.     struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
  184.     drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
  185.     int texAge;        /* last time texture was uploaded */
  186.     int ctxOwner;        /* last context to upload state */
  187.     int vertexPrim;
  188.  
  189.     /*
  190.      * Below is for XvMC.
  191.      * We want the lock integers alone on, and aligned to, a cache line.
  192.      * Therefore this somewhat strange construct.
  193.      */
  194.  
  195.     char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
  196.  
  197.     unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
  198.     unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
  199.     unsigned int XvMCCtxNoGrabbed;    /* Last context to hold decoder */
  200.  
  201.     /* Used by the 3d driver only at this point, for pageflipping:
  202.      */
  203.     unsigned int pfCurrentOffset;
  204. } drm_via_sarea_t;
  205.  
  206. typedef struct _drm_via_cmdbuf_size {
  207.     enum {
  208.         VIA_CMDBUF_SPACE = 0x01,
  209.         VIA_CMDBUF_LAG = 0x02
  210.     } func;
  211.     int wait;
  212.     uint32_t size;
  213. } drm_via_cmdbuf_size_t;
  214.  
  215. typedef enum {
  216.     VIA_IRQ_ABSOLUTE = 0x0,
  217.     VIA_IRQ_RELATIVE = 0x1,
  218.     VIA_IRQ_SIGNAL = 0x10000000,
  219.     VIA_IRQ_FORCE_SEQUENCE = 0x20000000
  220. } via_irq_seq_type_t;
  221.  
  222. #define VIA_IRQ_FLAGS_MASK 0xF0000000
  223.  
  224. enum drm_via_irqs {
  225.     drm_via_irq_hqv0 = 0,
  226.     drm_via_irq_hqv1,
  227.     drm_via_irq_dma0_dd,
  228.     drm_via_irq_dma0_td,
  229.     drm_via_irq_dma1_dd,
  230.     drm_via_irq_dma1_td,
  231.     drm_via_irq_num
  232. };
  233.  
  234. struct drm_via_wait_irq_request {
  235.     unsigned irq;
  236.     via_irq_seq_type_t type;
  237.     uint32_t sequence;
  238.     uint32_t signal;
  239. };
  240.  
  241. typedef union drm_via_irqwait {
  242.     struct drm_via_wait_irq_request request;
  243.     struct drm_wait_vblank_reply reply;
  244. } drm_via_irqwait_t;
  245.  
  246. typedef struct drm_via_blitsync {
  247.     uint32_t sync_handle;
  248.     unsigned engine;
  249. } drm_via_blitsync_t;
  250.  
  251. /* - * Below,"flags" is currently unused but will be used for possible future
  252.  * extensions like kernel space bounce buffers for bad alignments and
  253.  * blit engine busy-wait polling for better latency in the absence of
  254.  * interrupts.
  255.  */
  256.  
  257. typedef struct drm_via_dmablit {
  258.     uint32_t num_lines;
  259.     uint32_t line_length;
  260.  
  261.     uint32_t fb_addr;
  262.     uint32_t fb_stride;
  263.  
  264.     unsigned char *mem_addr;
  265.     uint32_t mem_stride;
  266.  
  267.     uint32_t flags;
  268.     int to_fb;
  269.  
  270.     drm_via_blitsync_t sync;
  271. } drm_via_dmablit_t;
  272.  
  273. #endif                /* _VIA_DRM_H_ */
  274.